package cn.iocoder.yudao.module.scenic.dal.mysql.comment;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.scenic.controller.admin.comment.vo.CommentPageByLocationReqVO;
import cn.iocoder.yudao.module.scenic.controller.admin.comment.vo.CommentPageByLocationResVO;
import cn.iocoder.yudao.module.scenic.controller.admin.comment.vo.CommentPageReqVO;
import cn.iocoder.yudao.module.scenic.dal.dataobject.comment.CommentDO;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 实践点评论 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CommentMapper extends BaseMapperX<CommentDO> {

    default PageResult<CommentDO> selectPage(CommentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CommentDO>()
                .eqIfPresent(CommentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(CommentDO::getContent, reqVO.getContent())
                .eqIfPresent(CommentDO::getIsShow, reqVO.getIsShow())
                .eqIfPresent(CommentDO::getCommentStatus,reqVO.getCommentStatus())
                .eqIfPresent(CommentDO::getSpotId, reqVO.getSpotId())
                .eqIfPresent(CommentDO::getSpotDeptId, reqVO.getSpotDeptId())
                .eqIfPresent(CommentDO::getStars, reqVO.getStars())
                .betweenIfPresent(CommentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CommentDO::getId));
    }

    IPage<CommentPageByLocationResVO> selectCommentListByCondition(IPage page, @Param("reqVo") CommentPageByLocationReqVO commentPageByLocationReqVO);

}